#ifndef INPUTMANAGER_H
#define INPUTMANAGER_H

#include "Singleton.h"
#include "SB.h"
#include "Vector3.h"

enum eMotionDirection {MOTION_NONE, MOTION_LEFT, MOTION_RIGHT, MOTION_UP, MOTION_DOWN};

class InputManager : public Singleton<InputManager>
{
private:
    bool m_bJustPressed;
    bool m_bJustMoved;
    bool m_bJustReleased;
    bool m_bPressed;
    Vector2 m_vPosition;
    
    // information of the latest just pressed
    float m_fTimeSinceLastJustPressed;
    Vector2 m_vLastJustPressedPos;
    
    // array of latest positions taken at given time (stored in the Z coord)
#define MAX_LATEST_POSITIONS        2
    Vector3 m_avLatestPositions[MAX_LATEST_POSITIONS];
    Vector2 m_vSpeed;
    
    eMotionDirection m_eMotionDirection;
    
public:
	
	InputManager();
	~InputManager();
	
public:
    bool hasJustPressed();
    bool hasJustMoved();
    bool hasJustReleased();
    bool isPressed();
    
    Vector2 getPosition();
    Vector2 getSpeed();
    Vector2 getLastJustPressedPosition();
    float getTimeSinceLastJustPressed();
    
    void setJustPressed(Vector2 _vPosition);
    void setJustMoved(Vector2 _vPosition);
    void setJustReleased(Vector2 _vPosition);
    
    bool positionInRect(Vector2 _vPos, Vector2 _vSize);

    void updateInputs();
    
    void setMotion(eMotionDirection _eDirection) { m_eMotionDirection = _eDirection; }
    eMotionDirection getMotionDirection() { return m_eMotionDirection; }
};

#endif